package com.haoze.common.dto;


import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

public class AgeDTO {
    /**
     * 住院日期
     */
    private String inDateTime;
    /**
     * 生日
     */
    private String birthday;
    private String ageYear;
    private String ageMonth;
    private String ageDay;
    private String ageHour;
    private String ageMinute;

    public String getInDateTime() {
        return inDateTime;
    }

    public void setInDateTime(String inDateTime) {
        this.inDateTime = inDateTime;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public String getAgeYear() {
        return ageYear;
    }

    public void setAgeYear(String ageYear) {
        this.ageYear = ageYear;
    }

    public String getAgeMonth() {
        return ageMonth;
    }

    public void setAgeMonth(String ageMonth) {
        this.ageMonth = ageMonth;
    }

    public String getAgeDay() {
        return ageDay;
    }

    public void setAgeDay(String ageDay) {
        this.ageDay = ageDay;
    }

    public String getAgeHour() {
        return ageHour;
    }

    public void setAgeHour(String ageHour) {
        this.ageHour = ageHour;
    }

    public String getAgeMinute() {
        return ageMinute;
    }

    public void setAgeMinute(String ageMinute) {
        this.ageMinute = ageMinute;
    }

    public  AgeDTO(){

    }

    public AgeDTO(Map<String,String> map){
        String inDateTime =formatValue(map.get("inDatetime"));
        String birthday = formatValue(map.get("birthDay"));
        //同名的问题，所以额外添加两个参数
        String inDateTime2 =formatValue(map.get("inDatetime2"));
        String birthday2 = formatValue(map.get("birthDay2"));
        String ageYear = formatValue(map.get("ageYear"));
        String ageMonth =formatValue(map.get("ageMonth")) ;
        String ageDay =formatValue( map.get("ageDay"));
        String ageHour =formatValue(map.get("ageHour")) ;
        String ageMinute =formatValue(map.get("ageMinute"));
        if(StringUtils.isNoneBlank(inDateTime2)&&StringUtils.isNoneBlank(birthday2)){
            this.inDateTime=inDateTime2;
            this.birthday=birthday2;
        }else{
            this.inDateTime=inDateTime;
            this.birthday=birthday;
        }

        this.ageYear=ageYear;
        this.ageMonth=ageMonth;
        this.ageDay=ageDay;
        this.ageHour=ageHour;
        this.ageMinute=ageMinute;
    }




    private String formatValue(String value) {
        final String defaultVale = "0";
        final String  wuValue="无";
        if (StringUtils.isBlank(value)) {
            return defaultVale;
        }
        if (wuValue.equals(value)) {
            return defaultVale;
        }
        return value;
    }
}
